<script lang="ts" setup>
import {
    listMeiYeOrder,
    payMeiYeOrder,
    userDeleteMeiYeOrder
} from '@/api/meiye.js'
import {
    myUserApi
} from '@/api/system.js'
import { onActivated, onMounted, reactive, ref } from 'vue'
import { store } from '@/stores/allStores'
import { pageList, showModal } from '@/util/bussinessTool';
import { isEmpty, isNotEmpty } from '@/util/localTool'
const active = ref('')
const navList = reactive([
    { title: '全部', name: '' },
    { title: '进行中', name: 'wait_worker_accept,wait_out,wait_reach,wait_start,service' },
    { title: '待评价', name: 'wait_user_comment' },
    { title: '已完成', name: 'complete' },
    { title: '已取消', name: 'user_cancel,overdue' }
])
const dataList = ref()
const loading = ref(false)
const workerPage = reactive(new pageList(listMeiYeOrder))
onActivated(() => {
    loadData()
})
function onChange() {
    loadData()
}
function loadData(value = 'refresh') {
    if (value === 'refresh') {
        workerPage.resetPage()
        workerPage.loadState = 'loading'
        dataList.value = []
    }
    let params = {
        statusEnum: active.value,
        descs: 'id',
    }
    workerPage.getData(params).then((res: any) => {
        if (isEmpty(res.data.page.records)) {
            workerPage.loadState = isEmpty(dataList.value) ? 'noData' : 'done'
            return
        }
        let records = res.data.page.records
        if (value === 'refresh') {
            dataList.value = records
        } else {
            dataList.value = dataList.value.concat(records)
        }
        workerPage.loadState = 'done'
        workerPage.pageData.current = records.length === 0 ? workerPage.pageData.current : (res.data.page.current + 1)
    }).catch(() => {
        workerPage.loadState = 'erro'
    })
}

function onRefresh() {
    loading.value = true
    setTimeout(() => {
        loading.value = false
    }, 2000)
}

</script>
<template>
    <!-- 
<van-tabs v-model:active="active" @change="onChange" :title-active-color="store.common.themeColorValue"
        :color="store.common.themeColorValue">
        <van-tab v-for="item in navList" :name="item.name" :title="item.title"></van-tab>
    </van-tabs>
    -->
    
    <van-pull-refresh v-model="loading" @refresh="onRefresh" style="min-height: 100vh;" >
       
    
    <pageLoading :load-state="workerPage.loadState" class="pageLoading">
        <template #default>
            <listCard v-for="(item, index) in dataList" :key="index" :data="item" @onPay="">
            </listCard>
            <div class="text-center	i-text-13 i-my-20 text-gray-300">没有更多数据了</div>
        </template>
    </pageLoading>
    </van-pull-refresh>
</template>
<style>
::-webkit-scrollbar {
    display: none;
}
</style>
